/**
 * The contents of this file are subject to the license and copyright detailed in the LICENSE and NOTICE files at the root of the source tree and available online at
 * http://www.askosi.org/license.html
 */
package be.destin.skos.core;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import be.destin.rdf.changes.Status;
import be.destin.skos.html.LocalError;
import be.destin.skos.html.SkosHtmlManager;
import be.destin.skos.search.LabelMatchType;
import be.destin.skos.search.SearchResult;

/**
 * @author Christophe Dupriez
 *
 */
public interface SchemeInterface {

	public static final char separator = '_';
	public static final char fieldSeparator = '\u0009'; // TAB character

	public static final String SESAME_NAMESPACE = "ConceptScheme:";
	
	public static final char joker_0_n = '*';
	/* TODO: NOT IMPLEMENTED YET!
	public static final char joker_1_1 = '?';
	public static final char joker_0_1 = '!';
	*/
	public static final char pieceBoundary = ' '; // In a search string, separates the different pieces to be searched
	
	public static final String skosNamespace = "http://www.w3.org/2004/02/skos/core#";

	public static final String keyRole = "id"; // Role providing access to one and only one record using an unambiguous key
	public static final String equationRole = "ql"; // Role providing access to a set of records using a query language (search equation)

	/**
	 * @return the concepts for an handle (redirected or not). Null if none
	 * The entry code can be a "magic" id
	 */
	public Concept findAbout_Concept(String handle);

	/**
	 * @return the code
	 */
	public String getAbout();

	/**
	 * @param application the application id with whom this scheme was opened
	 */
	public String getApplication();

	public String getAbout_About(String entryCode);

	/**
	 * @return the complete prefixed code of an entry (after applying redirection)
	 */
	public String getAbout_Concept(String handle);

	/**
	 * Sometime we need to marshall and there is no way to use easily another function.
	 * This one is therefore sometimes desactivated when marshalling a Scheme without the concepts. 
	 * @return the concepts
	 */
	public Collection<Concept> getConcept();
	/**
	 * Always get every concepts!
	 * @return the concepts
	 */
	public Collection<Concept> getAllConcepts();
	
	public Collection<ConceptIdentifier> getHasTopConcept();

	/**
	 * @return the concepts for a collection of handles
	 */
	public LinkedList<Concept> getConcept(Collection<String> handles);

	/**
	 * @return the concepts for an handle (redirected or not). Null if none
	 */
	public Concept getConcept(String handle);
	/**
	 * @return the displays
	 */
	public UrlList getDisplay();
	public String getDisplay(String language);
	public String getDisplayAdapted(SkosHtmlManager skosHtmlManager, Concept aConcept);
	/**
	 * @return the creation URL
	 */
	public UrlList getCreate();
	public String getCreate(String language);
	public String getCreateAdapted(SkosHtmlManager skosHtmlManager);
	/**
	 * @return the internal Note
	 */
	public String getInternalNote();

	/**
	 * @return the help
	 */
	public UrlList getHelp();

	/**
	 * @param language: language of need help
	 * @return help URL in desired language
	 */
	public String getHelp(String language);
	public String getHelpAdapted(SkosHtmlManager skosHtmlManager);
	/**
	 * @return the icons
	 */
	public UrlList getIcon();

	/**
	 * @return the icons
	 */
	public String getIcon(String language);
	public String getIconAdapted(SkosHtmlManager skosHtmlManager);

	/**
	 * @return namespace URL
	 */
	public String getNamespace();

	/**
	 * @return ConceptScheme URI
	 */
	public String getUri();

	public String getSchemaOrg();
	
	/**
	 * @param schemaOrg the schemaOrg to set
	 */
	public void setSchemaOrg(String schemaOrg);
	
	/**
	 * @return the titles
	 */
	public TermList getTitle();
	/**
	 * @return the descriptions
	 */
	public TermList getDescription();

	/**
	 * @return the rights
	 */
	public TermList getRights();
	/**
	 * @param language: language of need help
	 * @return help URL in desired language
	 */
	public String getTitle(String language);

	/**
	 * @param language: language of needed description
	 * @return description in desired language
	 */
	public String getDescription(String language);

	/**
	 * @param language: language of needed copyrights
	 * @return copyright in desired language
	 */
	public String getRights(String language);

	/**
	 * @param entry to put amongst concepts
	 * @return TODO
	 */
	public Concept putConcept(Concept entry);
	
	/**
	 * @param help the help to set
	 */
	public void putHelp(String help, String language);
	public void putDisplay(String display, String language);
	public void putCreate(String create, String language);
	public void putIcon(String icon, String language);


	public void putTitle(String name, TermFormat format, String language, Status status);
	
	public void putDescription(String description, TermFormat format, String language, Status status);

	public void putRights(String description, TermFormat format, String language, Status status);

	/**
	 * @param code the code to set
	 */
	public void setAbout(String code);
	
	/**
	 * @param application the application id with whom this scheme is opened
	 */
	public void setApplication(String application);
	
	/**
	 * @param conceptMap the concepts to set
	 */
	public void setConcept(List<Concept> someEntries);

	/**
	 * @param displays the displays to set
	 */
	public void setDisplay(UrlList displays);
	
	/**
	 * @param create URL to set
	 */
	public void setCreate(UrlList creates);
	
	/**
	 * @param titles the names to set
	 */
	public void setInternalNote(String note);

	/**
	 * @param help the help to set
	 */
	public void setHelp(UrlList help);

	/**
	 * @param icons the icons to set
	 */
	public void setIcon(UrlList icons);

	/**
	 * @param namespace: the namespace URI to set
	 */
	public void setNamespace(String namespace);

	/**
	 * @param uri: the ConceptScheme URI to set
	 */
	public void setUri(String uri);

	/**
	 * @param names the names to set
	 */
	public void setTitle(TermList names);

    /*
     * How many concepts in this scheme?
     */
	public int getSize();

	public ArrayList<SearchResult> labelMatch(String prefix, String userLanguage, boolean strictLanguage, LabelMatchType matchType);
	
	public ArrayList<SearchResult> labelMatch(String prefix, String userLanguage, boolean strictLanguage, LabelMatchType matchType, Collection<Concept> filter);

	public Concept getNotationConcept(String notationScheme, String handle);
    
    public SkosManager getManagerInstance();
    public void setManagerInstance(SkosManager managerInstance) ;
	
	/*
	 * Indicates that a Scheme initial load is finished
	 */
	public void preLoadFinished();
	
	public LocalError getErrors();
	/**
	 * @param errors the errors to set
	 */
	public void setErrors(LocalError errors);

	/**
	 * @return the lastLoaded
	 */
	public Date getLastLoaded();

	public String toStringLastLoaded();

	/**
	 * @param lastLoaded the lastLoaded to set
	 */
	public void setLastLoaded(Date lastLoaded);

	/**
	 * @return the supraLanguage
	 */
	public LinkedList<String> getSupraLanguage();

	/**
	 * @param supraLanguage the supraLanguage to set
	 */
	public void setSupraLanguage(LinkedList<String> supraLanguage);
	
	public LinkedList<String> getCreator();

	public void setCreator(LinkedList<String> creators);

	public LinkedList<String> getContributor();

	public void setContributor(LinkedList<String> contributors);

	public void addCreator(String creator);

	public void addContributor(String contributor);

	public boolean isHierarchized();
	
	public Concept getConceptRepresentation();
	
	public LinkedList<Status> getPossibleStatus(Profile userProfile, Status currentStatus, Status[][] normalTransitions);
	
	public long getLoadTime();
	public void setLoadTime(boolean finished);

	public long getMemorySpace();
	public void setMemorySpace(boolean finished);

	public boolean isNoConcepts();
	public void setNoConcepts(boolean noConcepts);
}
